package Demo01;
class Message {
    private String content;
    public void setContent(String content) {
        this.content = content;
    }
    public String getContent(){
        return content;
    }
}
class MessagePrint{
    public static void print(){
        System.out.println("【MessagePrint】" + Resource.MESSAGES.get().getContent());
    }
}
class Resource{
    public static final ThreadLocal<Message> MESSAGES = new ThreadLocal<>();
}
public class ThreadLocalDemo01 {
    public static void main(String[] args) throws Exception {
        String[] values = new String[] {"沐言科技：www.yootk.com","李兴华编程训练营：edu.yootk.com","课程讲师：李兴华"};
        for (String msg : values){
            new Thread(() ->{
                Resource.MESSAGES.set(new Message());
                Resource.MESSAGES.get().setContent(msg);
                MessagePrint.print();
            }).start();
        }
    }
}
